package com.tiger.life;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class CheckXingzuoActivity extends BaseActivity {
	private Bundle bundle;
	private Intent intent;
	private ListView datalist;
	private String[] data;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		bundle = this.getIntent().getExtras();

		intent = new Intent(this, ResultActivity.class);
		this.setContentView(R.layout.xingzuo_check);

		initView();
		initAction();
	}
	public void initView() {
		data=this.getResources().getStringArray(R.array.xingzuoContents);
		datalist=(ListView)this.findViewById(R.id.datalist);
		ArrayAdapter<String> a=new ArrayAdapter(this, R.layout.listviewlayout, data);
		datalist.setAdapter(a);
		datalist.setTextFilterEnabled(true);
		
	}
	public void initAction() {
		datalist.setOnItemClickListener(new OnItemClickListener(){

			@Override
			public void onItemClick(AdapterView<?> arg0, View v, int arg2,
					long arg3) {
				bundle.putInt(CommonUtil.xingzuoInter.index, (arg2+1));
				bundle.putString(CommonUtil.xingzuoInter.title, ((TextView) v).getText().toString());
				intent=new Intent(CheckXingzuoActivity.this,ResultActivity.class);
				intent.putExtras(bundle);
				CheckXingzuoActivity.this.startActivity(intent);
				// TODO Auto-generated method stub
			}
			
		});
	}
}
